package ldh.im.fxgui.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import ldh.im.fxbase.pojo.User;
import ldh.im.fxgui.util.UiUtil;

import java.net.URL;
import java.util.ResourceBundle;

public class UserInfoController implements Initializable {

    @FXML private TextField userNameTextField;
    @FXML private TextField userDescTextField;
    @FXML private ImageView headImageView;

    @FXML private TextField descTextField;
    @FXML private TextField areaTextField;
    @FXML private TextField wxTextField;
    @FXML private TextField fromTextField;

    private volatile User user;

    @FXML private void sendMsg(ActionEvent actionEvent) {
        MainController mainController = UiUtil.getMainController();
        if (mainController != null) {
            mainController.switchUserMessage(user);
        }
    }

    public void setUser(User user) {
        this.user = user;
        userNameTextField.setText(user.getUserName());
//        userDescTextField.setText(user.getDesc());

        Image image = new Image(this.getClass().getResource("/imgs/head.jpg").toExternalForm());
        headImageView.setImage(image);
    }

    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {

    }
}
